// 笔试强训day22：数组变换

#include <iostream>
using namespace std;

int main() {
    int n = 0, a = 0, common = 0;
    bool flag = true; 
    cin >> n;
    while(n--)
    {
        cin >> a;
        while(a % 2 == 0)
        {
            a /= 2;
        }
        if(common == 0)
            common = a;
        else if(a != common)
            flag = false;
    }

    if(flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}